<template>
    <!--树状分类列表 
  @desc 多级分类列表，同级项单一展开
  @author kyle
  @date 2021-06-07
  @props
    treeData  ———— 分类列表
    activeId ———— 当前选中项id
  @method
    treeClickEvent    ———— 点击单项事件
-->
    <view v-if="treeData && treeData.length > 0" class="spec-tree">
        <specTreeItem :data="data" :tree-data="treeData" :active-id="activeId" :min-num="minNum" :limit-buy="limitBuy"
            :is-single="isSingle" @treeClickEvent="treeClickEvent" @setCarListFunc="setCarListFunc" :tempType="tempType"
            :addNum="addNum" />
    </view>
</template>

<script>
import specTreeItem from "@/components/product/spec-tree-item.vue"
export default {
    name: "Tree",
    components: {
        specTreeItem,
    },
    props: {
        data: {
            // 数据
            type: Object,
            required: true,
        },
        // 树形控件数据
        treeData: {
            type: Array,
            default() {
                return []
            },
        },
        activeId: {
            type: Number,
            default: -1,
        },
        minNum: {
            type: Number,
            default: 0,
        },
        limitBuy: {
            type: Number,
            default: 0,
        },
        isSingle: {
            type: Boolean,
            default: false,
        },
        tempType: {
            type: Number,
            default: 0,
        },
        addNum: {
            type: Number,
            default: 1,
        },
    },
    data() {
        return {}
    },
    computed: {},
    mounted() { },
    methods: {
        setCarListFunc(obj) {
            this.$emit("setCarListFunc", obj)
        },
        treeClickEvent(item, index) {
            this.$emit("treeClickEvent", item, index)
        },
    },
}
</script>
<style lang="scss">
.spec-tree {
    padding: 0 $app-page-padding;
}
</style>
